package com.appspot.smartgan.adapter;

import com.appspot.smartgan.ChildInfoFragment;
import com.appspot.smartgan.ContactListFragment;
import com.appspot.smartgan.MessageBoardFragment;
import com.appspot.smartgan.PrivateMessagesFragment;
import com.appspot.smartgan.util.Child;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class TabsPagerAdapter extends FragmentPagerAdapter {

	private static final int NUMBER_OF_TABS = 4;
	
	// attribute
	private Child child;
	
	public TabsPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int index) {
		switch (index) {
		case 0:
			ChildInfoFragment childInfoFragment = new ChildInfoFragment();
			childInfoFragment.setChild(child);
			
			return childInfoFragment;
		case 1:
			MessageBoardFragment messageBoardFragment = new MessageBoardFragment();
			messageBoardFragment.setSchool(child.getSchoolId());
			
			return messageBoardFragment;
		case 2:
			PrivateMessagesFragment privateMessagesFragment =
					new PrivateMessagesFragment();
			privateMessagesFragment.setChild(child.getId());
			privateMessagesFragment.setSchool(child.getSchoolId());
			
			return new PrivateMessagesFragment();
		case 3:
			ContactListFragment contactListFragment = new ContactListFragment();
			contactListFragment.setSchool(child.getSchoolId());
			
			return contactListFragment;
		}
		
		return null;
	}

	@Override
	public int getCount() {
		return NUMBER_OF_TABS;
	}

	public void setChild(Child child) {
		this.child = child;
	}
	
}
